package com.yun.algorithmproblem.leetcode;

import java.util.HashMap;

public class Leetcode781 {

	public int numRabbits(int[] answers) {
		HashMap<Integer, Integer> map = new HashMap<>();
		int ans = 0;
		for (int answer : answers) {
			Integer currentNum = map.get(answer);
			if (currentNum == null || currentNum > answer) {
				ans += answer + 1;
				map.put(answer, 1);
				continue;
			}
			map.put(answer,currentNum+1);
		}
		return ans;
	}
}
